self.c.write (' * @fd_list: (allow-none): A #GUnixFDList or %NULL.\n')
for a in m.in_args:
self.c.write (' * @arg_%s: Argument passed by remote caller.\n'%(a.name))
self.c.write(self.docbook_gen.expand(
' *\n'
' * Signal emitted when a remote caller is invoking the %s.%s() D-Bus method.\n'
' *\n'
' * If a signal handler returns %%TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call %s_complete_%s() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %%G_DBUS_ERROR_UNKNOWN_METHOD error is returned.\n'
' *\n'
' * Returns: %%TRUE if the invocation was handled, %%FALSE to let other signal handlers run.\n'
self.c.write(' /* GObject properties for D-Bus properties: */\n')
for p in i.properties:
if p.readable and p.writable:
hint = 'Since the D-Bus property for this #GObject property is both readable and writable, it is meaningful to both read from it and write to it on both the service- and client-side.'
elif p.readable:
hint = 'Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.'
elif p.writable:
hint = 'Since the D-Bus property for this #GObject property is writable but not readable, it is meaningful to write to it on both the client- and service-side. It is only meaningful, however, to read from it on the service-side.'
else:
raise RuntimeError('Cannot handle property %s that neither readable nor writable'%(p.name))
self.c.write(' * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use %s_dup_%s() if on another thread.</warning>\n'
' *\n'
' * Returns: (transfer none): The property value or %%NULL if the property is not set. Do not free the returned value, it belongs to @object.\n'
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
unix_fd = True
# async begin
self.c.write('/**\n'
' * %s_call_%s:\n'
' * @proxy: A #%sProxy.\n'
%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.c.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
if unix_fd:
self.c.write(' * @fd_list: (allow-none): A #GUnixFDList or %NULL.\n')
self.c.write(self.docbook_gen.expand(
' * @cancellable: (allow-none): A #GCancellable or %%NULL.\n'
' * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %%NULL.\n'
' * @user_data: User data to pass to @callback.\n'
' *\n'
' * Asynchronously invokes the %s.%s() D-Bus method on @proxy.\n'
' * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.\n'
' * You can then call %s_call_%s_finish() to get the result of the operation.\n'
' *\n'
' * See %s_call_%s_sync() for the synchronous, blocking version of this method.\n'
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
unix_fd = True
self.c.write('/**\n'
' * %s_complete_%s:\n'
' * @object: A #%s.\n'
' * @invocation: (transfer full): A #GDBusMethodInvocation.\n'
%(i.name_lower, m.name_lower, i.camel_name))
if unix_fd:
self.c.write (' * @fd_list: (allow-none): A #GUnixFDList or %NULL.\n')
for a in m.out_args:
self.c.write(' * @%s: Parameter to return.\n'%(a.name))
self.c.write(self.docbook_gen.expand(
' *\n'
' * Helper function used in service implementations to finish handling invocations of the %s.%s() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.\n'
' *\n'
' * This method will free @invocation, you cannot use it afterwards.\n'
# For some property types, we have to free the returned
# value (or part of it, e.g. the container) because of how
# GVariant works.. see https://bugzilla.gnome.org/show_bug.cgi?id=657100
# for details
#
free_container = False;
if p.arg.gvariant_get == 'g_variant_get_strv' or p.arg.gvariant_get == 'g_variant_get_objpathv' or p.arg.gvariant_get == 'g_variant_get_bytestring_array':
free_container = True;
# If already using an old value for strv, objpathv, bytestring_array (see below),
# then just return that... that way the result from multiple consecutive calls
# to the getter are valid as long as they're freed
#
if free_container:
self.c.write(' value = g_datalist_get_data (&proxy->priv->qdata, \"%s\");\n'
if p.arg.gvariant_get == 'g_variant_get_string' or p.arg.gvariant_get == 'g_variant_get_strv' or p.arg.gvariant_get == 'g_variant_get_objv' or p.arg.gvariant_get == 'g_variant_get_bytestring_array':
extra_len = ', NULL'
self.c.write(' value = %s (variant%s);\n'%(p.arg.gvariant_get, extra_len))
' * @flags: Flags from the #GDBusProxyFlags enumeration.\n'
' * @name: (allow-none): A bus name (well-known or unique) or %%NULL if @connection is not a message bus connection.\n'
' * @object_path: An object path.\n'
' * @cancellable: (allow-none): A #GCancellable or %%NULL.\n'
' * @callback: A #GAsyncReadyCallback to call when the request is satisfied.\n'
' * @user_data: User data to pass to @callback.\n'
' *\n'
' * Asynchronously creates a proxy for the D-Bus interface #%s. See g_dbus_proxy_new() for more details.\n'
' *\n'
' * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.\n'
' * You can then call %s_proxy_new_finish() to get the result of the operation.\n'
' *\n'
' * See %s_proxy_new_sync() for the synchronous, blocking version of this constructor.\n'
' * @flags: Flags from the #GDBusProxyFlags enumeration.\n'
' * @name: A bus name (well-known or unique).\n'
' * @object_path: An object path.\n'
' * @cancellable: (allow-none): A #GCancellable or %%NULL.\n'
' * @callback: A #GAsyncReadyCallback to call when the request is satisfied.\n'
' * @user_data: User data to pass to @callback.\n'
' *\n'
' * Like %s_proxy_new() but takes a #GBusType instead of a #GDBusConnection.\n'
' *\n'
' * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.\n'
' * You can then call %s_proxy_new_for_bus_finish() to get the result of the operation.\n'
' *\n'
' * See %s_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.\n'
' g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);\n'
' g_value_unset (&return_value);\n'
)
self.c.write(' for (n = 0; n < num_params + num_extra; n++)\n'
' * This section contains the #%sObject, #%sObjectProxy, and #%sObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.\n'
' ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "%s");\n'
' if (ret == NULL)\n'
' return NULL;\n'
' return %s%s (ret);\n'
'}\n'
'\n'
%(i.name, self.ns_upper, i.name_upper))
self.c.write('\n')
for i in self.ifaces:
self.c.write(self.docbook_gen.expand(
'/**\n'
' * %sobject_peek_%s: (skip)\n'
' * @object: A #%sObject.\n'
' *\n'
' * Like %sobject_get_%s() but doesn\'t increase the reference count on the returned object.\n'
' *\n'
' * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>\n'
' *\n'
' * Returns: (transfer none): A #%s or %%NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.\n'
self.c.write(' ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));\n'
' if (ret == (GType) 0)\n'
' ret = G_TYPE_DBUS_PROXY;\n')
self.c.write(' return ret;\n'
'}\n'
'\n')
# constructors
self.c.write(self.docbook_gen.expand(
'/**\n'
' * %sobject_manager_client_new:\n'
' * @connection: A #GDBusConnection.\n'
' * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.\n'
' * @name: (allow-none): A bus name (well-known or unique) or %%NULL if @connection is not a message bus connection.\n'
' * @object_path: An object path.\n'
' * @cancellable: (allow-none): A #GCancellable or %%NULL.\n'
' * @callback: A #GAsyncReadyCallback to call when the request is satisfied.\n'
' * @user_data: User data to pass to @callback.\n'
' *\n'
' * Asynchronously creates #GDBusObjectManagerClient using %sobject_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.\n'
' *\n'
' * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.\n'
' * You can then call %sobject_manager_client_new_finish() to get the result of the operation.\n'
' *\n'
' * See %sobject_manager_client_new_sync() for the synchronous, blocking version of this constructor.\n'
' ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);\n'
' g_object_unref (source_object);\n'
' if (ret != NULL)\n'
' return G_DBUS_OBJECT_MANAGER (ret);\n'
' else\n'
' return NULL;\n'
'}\n'
'\n'
%(self.ns_lower))
self.c.write(self.docbook_gen.expand(
'/**\n'
' * %sobject_manager_client_new_sync:\n'
' * @connection: A #GDBusConnection.\n'
' * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.\n'
' * @name: (allow-none): A bus name (well-known or unique) or %%NULL if @connection is not a message bus connection.\n'
' * @object_path: An object path.\n'
' * @cancellable: (allow-none): A #GCancellable or %%NULL.\n'
' * @error: Return location for error or %%NULL\n'
' *\n'
' * Synchronously creates #GDBusObjectManagerClient using %sobject_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.\n'
' *\n'
' * The calling thread is blocked until a reply is received.\n'
' *\n'
' * See %sobject_manager_client_new() for the asynchronous version of this constructor.\n'
' *\n'
' * Returns: (transfer full) (type %sObjectManagerClient): The constructed object manager client or %%NULL if @error is set.\n'
' * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.\n'
' * @name: A bus name (well-known or unique).\n'
' * @object_path: An object path.\n'
' * @cancellable: (allow-none): A #GCancellable or %%NULL.\n'
' * @callback: A #GAsyncReadyCallback to call when the request is satisfied.\n'
' * @user_data: User data to pass to @callback.\n'
' *\n'
' * Like %sobject_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.\n'
' *\n'
' * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.\n'
' * You can then call %sobject_manager_client_new_for_bus_finish() to get the result of the operation.\n'
' *\n'
' * See %sobject_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.\n'